package com.quanyan.place.task.tracker;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.github.ltsopensource.core.domain.Action;
import com.github.ltsopensource.tasktracker.Result;
import com.github.ltsopensource.tasktracker.logger.BizLogger;
import com.github.ltsopensource.tasktracker.runner.JobContext;
import com.github.ltsopensource.tasktracker.runner.JobRunner;
import com.github.ltsopensource.tasktracker.runner.LtsLoggerFactory;
import com.quanyan.place.service.PlaceTaskService;

/**
 * @author SongFan
 * @date  2017年3月23日16:39:43
 * @Desc  场馆精彩活动更新
 */
@Component("placeWonderfulActivityTask")
public class PlaceWonderfulActivityTask implements JobRunner {
	
    private static final Logger LOGGER = LoggerFactory.getLogger(PlaceWonderfulActivityTask.class);
    @Autowired
    private PlaceTaskService placeTaskService;
    
    @Override
    public Result run(JobContext jobContext) throws Throwable {

        try {
            placeTaskService.placeWonderfulActivity();
            
            //会发送到 LTS (JobTracker上)
            BizLogger bizLogger = LtsLoggerFactory.getBizLogger();
            bizLogger.info("场馆精彩活动更新成功！");
        } catch (Exception e) {
        	
            LOGGER.info("Run job failed!", e);
            return new Result(Action.EXECUTE_LATER, "PlaceWonderfulActivityTask--更新场馆精彩活动状态任务执行失败，"+e.getMessage());
        }
        return new Result(Action.EXECUTE_SUCCESS, "更新场馆精彩活动状态任务执行成功。");
    }
}
